<?PHP
 
class Admin_report_Controller extends controller_admin{
	var $rpts = array(
		"user"=>array(
			'type_name'=>"会员报表",
			'reports'=>array(
				"user1"=>array('name'=>'会员信息','url'=>'/admin_report/user1','model'=>'user','action'=>'user1','remark'=>'')
			)	
		),
		"send"=>array(
			'type_name'=>"乐园卡报表",
			'reports'=>array(
				"send1"=>array('name'=>'乐园卡配送明细报表','url'=>'/admin_report/send1','model'=>'send','action'=>'send1','remark'=>''),
				"send2"=>array('name'=>'乐园卡配送菜品汇总','url'=>'/admin_report/send2','model'=>'send','action'=>'send2','remark'=>''),
				"send3"=>array('name'=>'乐园卡配送批次出货单','url'=>'/admin_report/send3','model'=>'send','action'=>'send3','remark'=>''),
				"send4"=>array('name'=>'乐园卡配送总体分析表','url'=>'/admin_report/send4','model'=>'send','action'=>'send4','remark'=>'')
			)
		),
		"order"=>array(
			'type_name'=>"田园卡报表",
			'reports'=>array(
				"order1"=>array('name'=>'田园卡订单出货单','url'=>'/admin_report/order1','model'=>'order','action'=>'order1','remark'=>''),
				"order2"=>array('name'=>'田园卡订单出货单(按订单号)','url'=>'/admin_report/order2','model'=>'order','action'=>'order2','remark'=>''),
				"order3"=>array('name'=>'田园卡配送菜品汇总','url'=>'/admin_report/order3','model'=>'order','action'=>'order3','remark'=>''),
				"order4"=>array('name'=>'田园卡配送菜品明细','url'=>'/admin_report/order4','model'=>'order','action'=>'order4','remark'=>'')
			)
		),
		"trans"=>array(
			'type_name'=>"电子账户报表",
			'reports'=>array(
				"trans1"=>array('name'=>'会员电子账户汇总报表','url'=>'/admin_report/trans1','model'=>'trans','action'=>'trans1','remark'=>''),
				"trans2"=>array('name'=>'会员电子账户明细报表','url'=>'/admin_report/trans2','model'=>'trans','action'=>'trans2','remark'=>'')
			)
		)
	);
	function __construct(){
		parent::__construct();
	 	$this->assign('nav','报表中心');
		$this->assign('menuid1','8');
		$this->assign('menuid2','1');
		//权限判断
		factory::module('admin')->authSys('report');
	}
	function index__(){
		$rs = $this->rpts;
		$this->assign('rs',$rs);
	}
	function result__(){
		if (strtoupper($_SERVER['REQUEST_METHOD']) == 'POST')
		{
			if(!isset($_POST['model']))				$_POST['model']			 = '';
			if(!isset($_POST['action']))			$_POST['action']		 = '';
			if(!isset($_POST['title']))				$_POST['title']			 = '';
			if(!isset($_POST['downloads']))	  $_POST['downloads']	 = '0';
			if(!isset($_POST['searchdata']))  $_POST['searchdata'] = '';
			$m_chuli = factory::module('report_'.$_POST['model']);
			$searchdata = format::addslash_json(json_decode( stripslashes($_POST['searchdata']) ));
			$report_result = $m_chuli->make($_POST['action'],$searchdata);
			if($_POST['downloads'] == '1'){
				$o_export_xls = new export_xls();
				$o_export_xls->export($report_result,$_POST['title']);
				exit();
			}
			$this->assign('report_title',$_POST['title']);
			$this->assign('report_result',$report_result);
		}
	}
	
	
	
	
	
	
	
	
	
	##################################
	# 会员报表
	################################## 
	#会员信息
	public function user1__(){
		$this->assign('rpt',$this->rpts['user']['reports']['user1']);
		
	}
	
	
	##################################
	# 乐园卡配送批次报表
	################################## 
	#乐园卡配送明细报表
	public function send1__(){
		$db = factory::getdbo();
		$rs = $db->loadassoclist('select * from t_sendpi where deleted=0  order by senddate desc   ');
		$this->assign('rs',$rs);
		$this->assign('rpt',$this->rpts['send']['reports']['send1']);
	}
	#乐园卡配送菜品汇总
	public function send2__(){
		$this->assign('rpt',$this->rpts['send']['reports']['send2']);
	}
	#乐园卡配送批次出货单
	public function send3__(){
		$db = factory::getdbo();
		$rs = $db->loadassoclist('select * from t_sendpi where deleted=0 order by senddate desc   ');
		$this->assign('rs',$rs);
		$this->assign('rpt',$this->rpts['send']['reports']['send3']);
	}
	#配送明细总体分析报表
	public function send4__(){
		$this->assign('rpt',$this->rpts['send']['reports']['send4']);
		
	}
	
 
	##################################
	# 田园卡报表
	################################## 
	public function order1__(){
		$this->assign('rpt',$this->rpts['order']['reports']['order1']);
	
	
	}
	public function order2__(){
		$this->assign('rpt',$this->rpts['order']['reports']['order2']);
	
	
	}
	public function order3__(){
		$this->assign('rpt',$this->rpts['order']['reports']['order3']);
	
	
	}
	public function order4__(){
		$this->assign('rpt',$this->rpts['order']['reports']['order4']);
	
	
	}
	
	
	##################################
	# 电子账户
	################################## 
	public function trans1__(){
		$this->assign('rpt',$this->rpts['trans']['reports']['trans1']);
		
	}
	public function trans2__(){
		$this->assign('rpt',$this->rpts['trans']['reports']['trans2']);
	
		
		$db = factory::getdbo();
		$rs_transtype = $db->loadassoclist('select * from t_transtype ');
		
		$this->assign('rs_transtype',$rs_transtype);
	
	}
	
}
?>